{
 "cells": [
  {
   "cell_type": "raw",
   "id": "1c4f9d85-e64f-4680-a937-1079d69d5c33",
   "metadata": {
    "raw_mimetype": "text/restructuredtext"
   },
   "source": [
    ".. _nb_dnsga2:"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f0a1dfd8-a241-4f73-b8db-3ed46ae7fd23",
   "metadata": {
    "tags": []
   },
   "source": [
    "# D-NSGA-II: Dynamic Multi-Objective Optimization Using Modified NSGA-II"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3d603308-5299-4d16-97ad-2c5019f5ce4c",
   "metadata": {},
   "source": [
    "The algorithm is implemented based on <cite data-cite=\"dnsga2\"></cite>. D-NSGA-II modifies the commonly-used NSGA-II procedure in tracking a new Pareto-optimal front as soon as there is a change in the problem. The introduction of a few random solutions or a few mutated solutions provides some diversity and gives the algorithm a chance to escape from a local optimum over time."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4a786da2-8c26-406e-ad1e-c6f0159793c1",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "from pymoo.algorithms.moo.dnsga2 import DNSGA2\n",
    "from pymoo.core.callback import CallbackCollection\n",
    "from pymoo.optimize import minimize\n",
    "from pymoo.problems.dyn import TimeSimulation\n",
    "from pymoo.problems.dynamic.df import DF1\n",
    "\n",
    "from pymoo.visualization.video.callback_video import ObjectiveSpaceAnimation\n",
    "\n",
    "problem = DF1(taut=2, n_var=2)\n",
    "\n",
    "algorithm = DNSGA2(version=\"A\")\n",
    "\n",
    "res = minimize(problem,\n",
    "               algorithm,\n",
    "               termination=('n_gen', 100),\n",
    "               callback=TimeSimulation(),\n",
    "               seed=1,\n",
    "               verbose=False)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
